#include "stdafx.h"
#include "InventoryMenu.h"
#include "base\Button.h"
#include "base\Checkbox.h"
#include "base\Button.h"
#include "base\ProgressBar.h"
#include "..\..\..\EdgeGameCore\Objects\Player\Player.h"
#include "..\..\..\EdgeGraphics\Fonts.h"
#include "CraftingMenu.h"
#include "../State Machine/GameplayState.h"

void onCraftingClicked(void**);

InventoryMenu::InventoryMenu(void)
{
	/***********************Temporary********************************/
	Checkbox* checkbox = new Checkbox();
	checkbox->setPosition(Vector2(10.f));

	elements.push_back(checkbox);
	
	hunger_bar = new ProgresBar();
	hunger_bar->setPosition(Vector2(10.f, 100.f));
	hunger_bar->setText("Hunger:");

	thurst_bar = new ProgresBar();
	thurst_bar->setPosition(Vector2(10.f, 175.f));
	thurst_bar->setText("Thurst:");

	exposure_bar = new ProgresBar();
	exposure_bar->setPosition(Vector2(10.f, 250.f));
	exposure_bar->setText("Exposure:");

	health_bar = new ProgresBar;
	health_bar->setPosition(Vector2(10.f, 325.f));
	health_bar->setText("Health");
	
	stamina_bar = new ProgresBar;
	stamina_bar->setPosition(Vector2(10.f, 400.f));
	stamina_bar->setText("Stamina");

	crafting_button = new Button("Content/Textures/button.mat", "Crafting");
	crafting_button->setPosition(Vector2(700.f, 100.f));
	crafting_button->setTextColor(vector_4::black);
	crafting_button->setFont(Fonts::GetInstance()->arial);
	crafting_button->OnClicked.Subscribe(Functor<mouse_event_handler>(&onCraftingClicked, 0));


	elements.push_back(thurst_bar);
	elements.push_back(hunger_bar);
	elements.push_back(exposure_bar);
	elements.push_back(health_bar);
	elements.push_back(stamina_bar);
	elements.push_back(crafting_button);
	/****************************************************************/

	lockMouse = false;
}

void onCraftingClicked(void** params)
{
	GameplayState::GetInstance()->getMenus()->setActiveMenu(CraftingMenu::GetInstance());
}

/*virtual*/ InventoryMenu::~InventoryMenu(void)
{

}

/*virtual*/ void InventoryMenu::Update(float dt) /*override*/
{
	hunger_bar->setValue(Player::GetInstance()->stats.hunger);
	thurst_bar->setValue(Player::GetInstance()->stats.thurst);
	exposure_bar->setValue(Player::GetInstance()->stats.exposure);
	health_bar->setValue(Player::GetInstance()->stats.health);
	stamina_bar->setValue(Player::GetInstance()->stats.stamina);

	Menu::Update(dt);
}

/*virtual*/ void InventoryMenu::Draw(void) /*override*/
{
	Menu::Draw();
}